package everyday;

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class T1630 {
    public List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {
        List<Boolean> list = new ArrayList<>();
        int len = nums.length;
        int m = l.length;
        for (int i = 0; i < m; i++) {
            int[] ints= Arrays.copyOfRange(nums,l[i],r[i]+1);
            Arrays.sort(ints);
            int diff=ints[1]-ints[0];
            boolean b=true;
            for (int j = 2; j <ints.length ; j++) {
                if (ints[j-1]+diff!=ints[j]){
                    b=false;
                    break;
                }
            }
            list.add(b);
        }
        return list;
    }


    @Test
    public void test() {
        System.out.println(checkArithmeticSubarrays(new int[]{4,6,5,9,3,7},new int[]{0,0,2},new int[]{2,3,5}));


    }
}
